package net.oschina.app.factory;


import android.support.v4.app.Fragment;

import net.oschina.app.fragment.technology_answer.TechColligateFragment;
import net.oschina.app.fragment.technology_answer.TechForumFragment;
import net.oschina.app.fragment.technology_answer.TechProfessionFragment;
import net.oschina.app.fragment.technology_answer.TechQuestionFragment;
import net.oschina.app.fragment.technology_answer.TechShareFragment;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by wei03 on 2017/1/13.
 */

public class TechnologyAndAnswerFactory extends BaseFactory{
    public  Fragment getFragment(int position) {
        Map<Integer, Fragment> fragments = new HashMap<>();
        Fragment fragment = fragments.get(position);
        if (fragment == null) {
            switch (position) {
                case 0:
                    fragment = new TechQuestionFragment();
                    break;
                case 1:
                    fragment = new TechShareFragment();
                    break;
                case 2:
                    fragment = new TechColligateFragment();
                    break;
                case 3:
                    fragment = new TechProfessionFragment();
                    break;
                case 4:
                    fragment = new TechForumFragment();
                    break;
                default:
                    fragment = new TechQuestionFragment();
            }
            fragments.put(position, fragment);
        }
        return fragment;
    }
}
